package org.gten.gegedexin.service.user.common;

public enum ResultCode {
    //成功状态
    SUCCESS(200,"成功。"),
    /*
     *失败状态
     */
    //未知异常
    UNKNOWN_ERR(9999,"未知错误！"),

    //系统错误(10000-19999)
    SYS_ERR(10000,"系统异常，请稍后重试！"),

    //参数错误(20000-29999)
    PARAM_IS_INVALID(20001,"参数无效！"),
    ACCOUNT_NOT_FOUND(20002,"未找到账号！"),
    PASSWORD_INCORRECT(20003,"密码错误！"),
    ACCOUNT_EXISTED(20011,"账号已存在！"),
    NO_LOGIN(20021,"未登录，请先登录！");


    private Integer code;

    private String message;

    ResultCode(Integer code,String message){
        this.code=code;
        this.message=message;
    }

    public Integer code(){
        return this.code;
    }

    public String message(){
        return this.message;
    }

    public Integer getCode(String name){
        for(ResultCode item : ResultCode.values()){
            if(item.name().equals(name)){
                return item.code;
            }
        }
        return null;
    }
    public String getMessage(String name){
        for(ResultCode item : ResultCode.values()){
            if(item.name().equals(name)){
                return item.message;
            }
        }
        return name;
    }

    @Override
    public String toString(){
        return this.name();
    }

}
